package com.example.tests;

import java.util.Random;
import org.testng.annotations.Test;
import com.example.utils.SortedListOf;
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.*;

public class GroupDeletion extends AddressbookTestBase {

	@Test(dataProvider = "randomValidGroupGenerator")
	public void deleteSomeGroup(){
		//save old state
		SortedListOf<GroupData> oldList = app.getGroupHelper().getGroups();
		//prereq - fullfill list
		Random rnd = new Random();
		int index = rnd.nextInt(oldList.size()-1);	
		//actions
		app.getGroupHelper().deleteGroup(index);
		//save new state
		SortedListOf<GroupData> newList = app.getGroupHelper().getGroups();			
		//compare states			
		assertThat(newList, equalTo(oldList.without(index)));
	}
}
